#pragma once
#include "ShortReadUtil.h"
#include <vector>
#include <algorithm>
using namespace std;

// assume junciton start and end are in exon.
class CJunction
{
public:
    CJunction(void);
    CJunction(int start, int end);
    CJunction(char* line);
    ~CJunction(void);
    bool operator<(const CJunction &other) const;
    int start;
    int end;
    unsigned int support;
    char strand;
};

class CJunctions
{
public:
    CJunctions(string GeneName, bool forward);
    ~CJunctions(void);
    string geneName;
    bool forward;
    vector<CJunction> JunctionsV;
    int addJunction(CJunction junction);
    int addJunctions(vector< pair <int, int> >& num_pair, bool forward);
    void sortJunctions(bool forward);
    vector<CJunction>::iterator nextJunction(int start, int end);
};

class CForwardComp
{   // Compare functor for forward junctions
public:
    CForwardComp () {
        ;
    }
    ~CForwardComp () {
        ;
    }
    bool operator()(CJunction j1, CJunction j2) {
        return(( j1.start < j2.start ) || ( j1.start == j2.start && j1.end < j2.end ));
    }
};

class CBackwardComp
{   // Compare functor for forward junctions
public:
    CBackwardComp() {
        ;
    }
    ~CBackwardComp() {
        ;
    }
    bool operator()(CJunction j1, CJunction j2) {
        return(( j1.end > j2.end ) || ( j1.end == j2.end && j1.start > j2.start ));
    }
};

int checkJunctionStrand(const char* seq, CJunction& j);
